package com.copsoftware.db;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.util.LabelValueBean;

import com.copsoftware.comun.interfaces.IDAODataLoader;
import com.copsoftware.exceptionutils.DAODataLoaderException;
import com.copsoftware.exceptionutils.ErrorLevel;
import com.copsoftware.utils.BeanBuilder;

public class DAODataLoader extends DAOSession implements IDAODataLoader{
	
	protected final Log logger = LogFactory.getLog(getClass());
	
	public List list(String query) throws DAODataLoaderException {
		logger.info(query);
		List lvList = null;
		try {
		lvList = getSession().createQuery(query).list();
		
			return  BeanBuilder.procesarFila(lvList, LabelValueBean.class);
		} catch (Exception e) {
			// TODO Auto-generated catch block	
			throw new DAODataLoaderException(e.getCause(),"error.dataloader.load",null,ErrorLevel.ERROR); 
		}
	}
}
